<template>
  <div class="foot-tab  vux-demo-tabbar">
    <a v-if="this.$route.path.indexOf('/index')>-1" href="javascript:;" class="router-link-active"><i class="foot-bg1"></i> <p>苏鲜生</p></a>
    <router-link v-else :to="'/index'">
      <i class="foot-bg1"></i>
        <p>苏鲜生</p>
    </router-link>
    <router-link  :to="'/list'">
      <i class="foot-bg2"></i>
        <p>分类</p>
    </router-link>
    <router-link  :to="'/cart1'">
        <i class="foot-bg3">
            <span class="footer-cart-num" v-text="cartsNumber"></span>
        </i>
        <p>购物车</p>
        
    </router-link>
    <router-link  :to="'/my'">
        <i class="foot-bg4"></i>
        <p>我的</p>
    </router-link>  
  </div>


</template>
<script>
  import { mapGetters } from 'vuex'
  // import { Tabbar, TabbarItem} from 'vux'
  export default {
    // components: {
    //   Tabbar,
    //   TabbarItem
    // },
    data() {
      return {
         
      }
    },
    mounted(){
      this.$nextTick(() => {
        if(!this.cartsNumber){
          this.$store.dispatch("getSufreshProducts")
          this.$store.dispatch("getCenterProducts")
        }
      });
    }, 
    computed: mapGetters([
      'cartsNumber'
    ]),
  }
</script>

<style lang="less" scoped>
  .foot-tab{
      padding-top: 0.32rem;
      display: flex;
      position: absolute;
      z-index: 500;
      bottom: 0;
      width: 100%;
      background-color: #f7f7fa;
      height: 2.1rem;
      a{
        display: block;
        flex: 1;
        width: 25%;
        text-align: center;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
        position: relative;
        color: #353d44;
      }
  }
  .foot-tab i{
      display: inline-block;
      width: 0.88rem;
      height: 0.88rem;
      position: relative;
      top: 0.05rem;
      background-size: 100% 100%;
      &.foot-bg1 {
        background-image: url(foot/tab_home.png);
      }
      &.foot-bg2 {
        background-image: url(foot/tab_classify.png);
      }
      &.foot-bg3 {
        background-image: url(foot/tab_shopcart.png);
      }
      &.foot-bg4 {
        background-image: url(foot/tab_me.png);
      }
  }

  .foot-tab p {
    height: 0.6rem;
    line-height:0.6rem;
    position: relative;
    top: -0.04rem;
  }
  .foot-tab:before {
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: 1px;
    border-top: 1px solid #c0bfc4;
    color: #c0bfc4;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: scaleY(.5);
    transform: scaleY(.5);
}
.foot-tab .router-link-active i{
      &.foot-bg1 {
        background-image: url(foot/tab_home_s.png);
      }
      &.foot-bg2 {
        background-image: url(foot/tab_classify_s.png);
        
      }
      &.foot-bg3 {
        background-image: url(foot/tab_shopcart_s.png);
      }
      &.foot-bg4 {
        background-image: url(foot/tab_me_s.png);
      }
}
.foot-tab .router-link-active p {
  color: #ff782d;
}

.vux-badge-single {
    padding: 0;
    min-width: 16px;
}

.vux-badge {
    position: absolute;
    top: -8px;
    left: 100%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    z-index: 2;
}
.vux-badge {
    text-align: center;
    background: #ff9d67;
    color: #fff;
    font-size: 12px;
    height: 16px;
    line-height: 16px;
    border-radius: 8px;
    padding: 0 5px;
    background-clip: padding-box;
    vertical-align: middle;
    text-align: center;
}


.footer-cart-num {
    background: #ff9d67;
    color: #fff;
    font-size: .4rem;
    height: .56rem;
    line-height: .56rem;
    min-width: .56rem;
    padding: 0 .1rem;
    border-radius: .28rem;
    vertical-align: middle;
    text-align: center;
    position: absolute;
    top: -.22rem;
    right: -.32rem;
    z-index: 2;
}
</style>
